<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@page import="com.lmpop.trade.ti_aboutchannel.*" %>
<%@page import="java.util.*" %>
<%@page import="com.lmpop.frame.util.PageTools" %>
<%
	request.setCharacterEncoding("UTF-8");
	Ti_aboutchannel ti_aboutchannel = new Ti_aboutchannel();
	Ti_aboutchannelInfo ti_aboutchannelInfo = new Ti_aboutchannelInfo();
	String ch_namex = "";
	if(request.getParameter("ch_namex")!=null && !request.getParameter("ch_namex").equals("")){
		ch_namex = request.getParameter("ch_namex");
		ti_aboutchannel.setCh_name(ch_namex);
	}
	String break_ch_id = "";
	String ch_idx = "";
	if (request.getParameter("up_ch_id")!=null && !request.getParameter("up_ch_id").equals("")) 
	{
		ch_idx = request.getParameter("up_ch_id");
		if(!ch_idx.equals("000000000000000")){
		break_ch_id=ti_aboutchannelInfo.getUp_ch_id(ch_idx);
		 }
	}
 	else
 	{
		ch_idx="000000000000000";
	}
	ti_aboutchannel.setUp_ch_id(ch_idx);
	
	String n_aboutch_state = "";
	if(request.getParameter("aboutch_state")!=null && !request.getParameter("aboutch_state").equals("")){
		n_aboutch_state = request.getParameter("aboutch_state");
		ti_aboutchannel.setState(n_aboutch_state);
	}
	
	
	String iStart = "0";
	int limit = 20;
	if(request.getParameter("iStart")!=null) iStart = request.getParameter("iStart");
	List list = ti_aboutchannelInfo.getListByPage(ti_aboutchannel,Integer.parseInt(iStart),limit);
	int counter = ti_aboutchannelInfo.getCountByObj(ti_aboutchannel);
	String pageString = new PageTools().getGoogleToolsBar(counter,"index.jsp?ch_namex="+ch_namex+"&up_ch_id="+ch_idx+"&aboutch_state="+n_aboutch_state+"&iStart=",Integer.parseInt(iStart),limit);
	String para =	"ch_namex="+ch_namex+"&up_ch_id="+ch_idx+"&aboutch_state="+n_aboutch_state+"&iStart="+Integer.parseInt(iStart)+"&limit="+limit;
%>
<html>
  <head>
    
    <title>栏目管理</title>
		<link href="/program/admin/index/css/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="/js/commen.js"></script>
		<script type="text/javascript" src="aboutchannel.js"></script>
</head>

<body>
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td width="90%">
				<h1>栏目管理</h1>
			</td>
			<td>
				<a href="addInfo.jsp"><img src="/program/admin/index/images/post.gif" /></a>
			</td>
		</tr>
	</table>
	
	<form action="index.jsp" name="indexForm" method="post">
		
	<table width="100%" cellpadding="0" cellspacing="0" class="dl_su">
		<tr>
			<td align="left" >
				栏目名称:<input name="ch_namex" id="ch_namex" type="text" />&nbsp;&nbsp;
				栏目状态:<select name="aboutch_state"  id="aboutch_state">
					<option value="">请选择</option>
					<option value="0">显示</option>
					<option value="1">隐藏</option>
				</select>
				<input name="searchInfo" type="button" value="查询" onclick="searchForm()"/>
			</td>
		</tr>
	</table>

	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
		<% 
			int listsize = 0;
			if(list!=null && list.size()>0){
				listsize = list.size();
		%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
				<%if(!ch_idx.equals("000000000000000")){%>
			     	<input type="button" class="buttab" name="fanhui" value="返回" onClick="location.href='index.jsp?up_ch_id=<%=break_ch_id%>'" style="cursor:pointer;">
			<%}%>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	
	<table width="100%" cellpadding="1" cellspacing="1" class="listtab" border="0">
		<tr>
			<th width="5%" align="center"><input type="checkbox" name="checkall" id="checkall" onclick="selectAll()"></th>
				
				
				
		  	<th>栏目名称</th>
		  	
		  	<th>上级分类</th>
		  	
		  	<th>级别</th>
			
		  	<th>顺序</th>
			
		  	<th>状态</th>
		  	
		  	<th>新增子分类</th>
		  	
				<th width="10%">修改</th>
	  		<th width="10%">删除</th>
		</tr>
		<% 
		  		for(int i=0;i<list.size();i++){
		  			Hashtable map = (Hashtable)list.get(i);
		  			String ch_id="",ch_name="",ch_level="",state="",order_no="";
  			  	if(map.get("ch_id")!=null) ch_id = map.get("ch_id").toString();
				  	if(map.get("ch_name")!=null) ch_name = map.get("ch_name").toString();
				  	if(map.get("ch_level")!=null) ch_level = map.get("ch_level").toString();
				  	if(map.get("state")!=null) state = map.get("state").toString();
				  	if(map.get("order_no")!=null) order_no = map.get("order_no").toString();
						
						int child = ti_aboutchannelInfo.checkChild(ch_id);
						
						String up_ch_name="";
           	if(!ch_idx.equals("000000000000000")){
           		up_ch_name = "<a href=index.jsp?up_ch_id=" + ch_idx + ">" + ti_aboutchannelInfo.getChName(ch_idx) + "</a>";		 
						}
						else{
		          up_ch_name="无上级";
		        }
		        
		        String stateStr = "";
		        if(state.equals("0")){
		        	stateStr = "<a href=index.jsp?aboutch_state="+state+">"+"显示</a>";
		        }else if(state.equals("1")){
		        	stateStr = "<a href=index.jsp?aboutch_state="+state+">"+"隐藏</a>";
		        }
		        
		        String level="";
		        if(ch_level != null && !ch_level.equals("")){
		        	level=String.valueOf(Integer.parseInt(ch_level)+1);
		        }
		  %>
		
		<tr>
			<td width="5%" align="center">
				<input type="checkbox" name="checkone<%=i %>" id="checkone<%=i %>" value="<%=ch_id %>" />
				<input type="hidden" name="child<%=i %>" id="child<%=i %>" value="<%=child %>">
				</td>
				
				
				
	  		<td>
	  			<% if(child==1){ %>						
						<a href="index.jsp?up_ch_id=<%=ch_id %>&ch_level=<%=ch_level %>" title="点击进入子栏目！">
							<img src="/program/admin/images/1.gif" border="0"/>&nbsp;<%=ch_name %></a>
						<%}else if(child==0){%>
							<font color="black"><%=ch_name %></font>
						<%}%>
	       </td>
		  	<td><%=up_ch_name %></td>
		  	
		  	<td><%=ch_level %></td>
			
				<td><%=order_no %></td>
		  	
		  	<td><%=stateStr %></td>
		  	
		  	<td><a href="addInfo.jsp?up_ch_id=<%=ch_id%>&ch_level=<%=level%>" >
		  		<img src="/program/admin/images/add.gif" width="16" height="16" border="0" alt="新增下级频道">
		  		</a></td>
		  	
			<td width="10%"><a href="updateInfo.jsp?ch_id=<%=ch_id %>&<%=para%>"><img src="/program/admin/images/edit.gif" title="修改" /></a></td>
	  		<td width="10%"><a href="javascript:delOneNews('<%=i %>','<%=ch_id %>');"><img src="/program/admin/images/delete.gif" title="删除" /></a></a></td>
		</tr>
		
		  <%
		  		}
		  %>
		
	</table>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="dl_bg">
		<tr>
			<td width="90%">
				<input type="button" name="delInfo" onclick="delIndexInfo()" value="删除" class="buttab"/>
				<%if(!ch_idx.equals("000000000000000")){%>
			     	<input type="button" class="buttab" name="fanhui" value="返回" onClick="location.href='index.jsp?up_ch_id=<%=break_ch_id%>'" style="cursor:pointer;">
			<%}%>
			</td>
			<td>
				总计:<%=counter %>条
			</td>
		</tr>
	</table>
	<table width="100%" cellpadding="0" cellspacing="0" border="0" class="tablehe">
		<tr><td><%=pageString %></td></tr>
	</table>
	
	<%
		 }
	%>
	
	<table width="100%" cellpadding="0" cellspacing="0" border="0">
		<tr>
			<td align="center">
				<input type="button" class="buttoncss" name="tradeRut" value="返回" onclick="window.location.href='index.jsp';"/>
			</td>
		</tr>
	</table>
	
		<input type="hidden" name="up_ch_id" id="up_ch_id" value="<%=ch_idx %>" />
	  <input type="hidden" name="listsize" id="listsize" value="<%=listsize %>" />
	  <input type="hidden" name="pkid" id="pkid" value="" />
	  <input type="hidden" name="bpm_id" id="bpm_id" value="3336" />
	  </form>
</body>

</html>
